package com.hl.sfzy.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hl.sfzy.entity.Free;
import com.hl.sfzy.mapper.FreeMapper;
import com.hl.sfzy.service.FreeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class FreeServiceImpl implements FreeService {
    @Autowired
    private FreeMapper freeMapper;
    @Override
    public int deleteById(Integer id) {
        return freeMapper.deleteById(id);
    }

    @Override
    public int insert(Free free) {
        return freeMapper.insert(free);
    }

    @Override
    public Free selectById(Integer id) {
        return freeMapper.selectById(id);
    }

    @Override
    public int update(Free free) {
        return freeMapper.update(free);
    }

    @Override
    public List<Free> selectAll() {
        return freeMapper.selectAll();
    }
    @Override
    public PageInfo<Free> findByPage(int pageNum, int pageSize, Free free) {
        PageHelper.startPage(pageNum,pageSize);
        List<Free> frees = freeMapper.findByPage(pageNum,pageSize,free);
        PageInfo<Free> pageInfo = new PageInfo<>(frees);
        return pageInfo;
    }
}
